package org.vacoor.xqq.ui.chat;

import org.vacoor.xqq.ui.dynamictree.Buddy;
import org.vacoor.xqq.ui.dynamictree.BuddyNode;
import org.vacoor.xqq.ui.dynamictree.NotifyTree;

/**
 * User: Vacoor
 */
public class UIBuddyManager implements BuddyManager {
    final NotifyTree buddies;

    public UIBuddyManager(NotifyTree buddies) {
        this.buddies = buddies;
    }

    @Override
    public Buddy getBuddy(long id) {
        BuddyNode n = (BuddyNode) buddies.getIdentifiableAndObservableNode(id);
        return n != null ? n.getData() : null;
    }

    @Override
    public void notifyUser(Long id) {
        buddies.addNotify(id);
    }

    @Override
    public void cancelNotify(Long id) {
        buddies.removeNotify(id);
    }
}
